package com.itheima;

public class Student implements Comparable<Student> {
    private String name;
    private int age;
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(Student o) {
        // 按照学生年龄的正序排序（当前学生的年龄-被比较学生的年龄）
        //this指当前对象
        //return this.getAge() - o.getAge();

        //按照学生年龄的倒序排序（被比较学生的年龄-当前学生的年龄）
        return o.getAge() - this.getAge();
    }

}
